package com.mongodb.demo;/*
package com.mongodb.document.geoJson;

import org.bson.Document;
import org.springframework.core.convert.converter.Converter;

*/


import org.bson.Document;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.ReadingConverter;

/**
 * @author zhangbowen
 * @date 2019/5/9
 **/
@ReadingConverter
public class CustomReadGeoJsonConverter implements Converter<Document, CustomGeoJson> {
    @Override
    public CustomGeoJson convert(Document document) {
        CustomGeoJson geoJson = new CustomGeoJson();
        geoJson.setType(document.get(GeoJsonConstant.TYPE, String.class));
        geoJson.setCoordinates(document.get(GeoJsonConstant.COORDINATES, Iterable.class));
        return geoJson;
    }
}

